{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 问题：小费字段，与哪些因素相关最大"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据集字段说明\n",
    "- 消费总金额(totall_bill)(不含小费)\n",
    "- 小费金额(tip)\n",
    "- 顾客性别(sex)\n",
    "- 消费的星期(day)\n",
    "- 消费的时间段(time)\n",
    "- 用餐人数(size)\n",
    "- 顾客是否抽烟(smoker)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_excel(\"小费数据集.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>total_bill</th>\n",
       "      <th>tip</th>\n",
       "      <th>sex</th>\n",
       "      <th>smoker</th>\n",
       "      <th>day</th>\n",
       "      <th>time</th>\n",
       "      <th>size</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16.99</td>\n",
       "      <td>1.01</td>\n",
       "      <td>Female</td>\n",
       "      <td>No</td>\n",
       "      <td>Sun</td>\n",
       "      <td>Dinner</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10.34</td>\n",
       "      <td>1.66</td>\n",
       "      <td>Male</td>\n",
       "      <td>No</td>\n",
       "      <td>Sun</td>\n",
       "      <td>Dinner</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>21.01</td>\n",
       "      <td>3.50</td>\n",
       "      <td>Male</td>\n",
       "      <td>No</td>\n",
       "      <td>Sun</td>\n",
       "      <td>Dinner</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   total_bill   tip     sex smoker  day    time  size\n",
       "0       16.99  1.01  Female     No  Sun  Dinner     2\n",
       "1       10.34  1.66    Male     No  Sun  Dinner     3\n",
       "2       21.01  3.50    Male     No  Sun  Dinner     3"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 全都转换成数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_dummpies = pd.get_dummies(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>total_bill</th>\n",
       "      <th>tip</th>\n",
       "      <th>size</th>\n",
       "      <th>sex_Female</th>\n",
       "      <th>sex_Male</th>\n",
       "      <th>smoker_No</th>\n",
       "      <th>smoker_Yes</th>\n",
       "      <th>day_Fri</th>\n",
       "      <th>day_Sat</th>\n",
       "      <th>day_Sun</th>\n",
       "      <th>day_Thur</th>\n",
       "      <th>time_Dinner</th>\n",
       "      <th>time_Lunch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16.99</td>\n",
       "      <td>1.01</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10.34</td>\n",
       "      <td>1.66</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>21.01</td>\n",
       "      <td>3.50</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>23.68</td>\n",
       "      <td>3.31</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>24.59</td>\n",
       "      <td>3.61</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>239</th>\n",
       "      <td>29.03</td>\n",
       "      <td>5.92</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>240</th>\n",
       "      <td>27.18</td>\n",
       "      <td>2.00</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>241</th>\n",
       "      <td>22.67</td>\n",
       "      <td>2.00</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242</th>\n",
       "      <td>17.82</td>\n",
       "      <td>1.75</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>243</th>\n",
       "      <td>18.78</td>\n",
       "      <td>3.00</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>244 rows × 13 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     total_bill   tip  size  sex_Female  sex_Male  smoker_No  smoker_Yes  \\\n",
       "0         16.99  1.01     2           1         0          1           0   \n",
       "1         10.34  1.66     3           0         1          1           0   \n",
       "2         21.01  3.50     3           0         1          1           0   \n",
       "3         23.68  3.31     2           0         1          1           0   \n",
       "4         24.59  3.61     4           1         0          1           0   \n",
       "..          ...   ...   ...         ...       ...        ...         ...   \n",
       "239       29.03  5.92     3           0         1          1           0   \n",
       "240       27.18  2.00     2           1         0          0           1   \n",
       "241       22.67  2.00     2           0         1          0           1   \n",
       "242       17.82  1.75     2           0         1          1           0   \n",
       "243       18.78  3.00     2           1         0          1           0   \n",
       "\n",
       "     day_Fri  day_Sat  day_Sun  day_Thur  time_Dinner  time_Lunch  \n",
       "0          0        0        1         0            1           0  \n",
       "1          0        0        1         0            1           0  \n",
       "2          0        0        1         0            1           0  \n",
       "3          0        0        1         0            1           0  \n",
       "4          0        0        1         0            1           0  \n",
       "..       ...      ...      ...       ...          ...         ...  \n",
       "239        0        1        0         0            1           0  \n",
       "240        0        1        0         0            1           0  \n",
       "241        0        1        0         0            1           0  \n",
       "242        0        1        0         0            1           0  \n",
       "243        0        0        0         1            1           0  \n",
       "\n",
       "[244 rows x 13 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_dummpies"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 计算相关性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>total_bill</th>\n",
       "      <th>tip</th>\n",
       "      <th>size</th>\n",
       "      <th>sex_Female</th>\n",
       "      <th>sex_Male</th>\n",
       "      <th>smoker_No</th>\n",
       "      <th>smoker_Yes</th>\n",
       "      <th>day_Fri</th>\n",
       "      <th>day_Sat</th>\n",
       "      <th>day_Sun</th>\n",
       "      <th>day_Thur</th>\n",
       "      <th>time_Dinner</th>\n",
       "      <th>time_Lunch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>total_bill</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.675734</td>\n",
       "      <td>0.598315</td>\n",
       "      <td>-0.144877</td>\n",
       "      <td>0.144877</td>\n",
       "      <td>-0.085721</td>\n",
       "      <td>0.085721</td>\n",
       "      <td>-0.086168</td>\n",
       "      <td>0.054919</td>\n",
       "      <td>0.122953</td>\n",
       "      <td>-0.138174</td>\n",
       "      <td>0.183118</td>\n",
       "      <td>-0.183118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tip</th>\n",
       "      <td>0.675734</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.489299</td>\n",
       "      <td>-0.088862</td>\n",
       "      <td>0.088862</td>\n",
       "      <td>-0.005929</td>\n",
       "      <td>0.005929</td>\n",
       "      <td>-0.055463</td>\n",
       "      <td>-0.002790</td>\n",
       "      <td>0.125114</td>\n",
       "      <td>-0.095879</td>\n",
       "      <td>0.121629</td>\n",
       "      <td>-0.121629</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>size</th>\n",
       "      <td>0.598315</td>\n",
       "      <td>0.489299</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.086195</td>\n",
       "      <td>0.086195</td>\n",
       "      <td>0.133178</td>\n",
       "      <td>-0.133178</td>\n",
       "      <td>-0.142184</td>\n",
       "      <td>-0.041121</td>\n",
       "      <td>0.193054</td>\n",
       "      <td>-0.072598</td>\n",
       "      <td>0.103411</td>\n",
       "      <td>-0.103411</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sex_Female</th>\n",
       "      <td>-0.144877</td>\n",
       "      <td>-0.088862</td>\n",
       "      <td>-0.086195</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>0.002816</td>\n",
       "      <td>-0.002816</td>\n",
       "      <td>0.071060</td>\n",
       "      <td>-0.053957</td>\n",
       "      <td>-0.168106</td>\n",
       "      <td>0.194445</td>\n",
       "      <td>-0.205231</td>\n",
       "      <td>0.205231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sex_Male</th>\n",
       "      <td>0.144877</td>\n",
       "      <td>0.088862</td>\n",
       "      <td>0.086195</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.002816</td>\n",
       "      <td>0.002816</td>\n",
       "      <td>-0.071060</td>\n",
       "      <td>0.053957</td>\n",
       "      <td>0.168106</td>\n",
       "      <td>-0.194445</td>\n",
       "      <td>0.205231</td>\n",
       "      <td>-0.205231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>smoker_No</th>\n",
       "      <td>-0.085721</td>\n",
       "      <td>-0.005929</td>\n",
       "      <td>0.133178</td>\n",
       "      <td>0.002816</td>\n",
       "      <td>-0.002816</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-0.244316</td>\n",
       "      <td>-0.155744</td>\n",
       "      <td>0.181624</td>\n",
       "      <td>0.128534</td>\n",
       "      <td>-0.054921</td>\n",
       "      <td>0.054921</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>smoker_Yes</th>\n",
       "      <td>0.085721</td>\n",
       "      <td>0.005929</td>\n",
       "      <td>-0.133178</td>\n",
       "      <td>-0.002816</td>\n",
       "      <td>0.002816</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.244316</td>\n",
       "      <td>0.155744</td>\n",
       "      <td>-0.181624</td>\n",
       "      <td>-0.128534</td>\n",
       "      <td>0.054921</td>\n",
       "      <td>-0.054921</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>day_Fri</th>\n",
       "      <td>-0.086168</td>\n",
       "      <td>-0.055463</td>\n",
       "      <td>-0.142184</td>\n",
       "      <td>0.071060</td>\n",
       "      <td>-0.071060</td>\n",
       "      <td>-0.244316</td>\n",
       "      <td>0.244316</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.216319</td>\n",
       "      <td>-0.195451</td>\n",
       "      <td>-0.169608</td>\n",
       "      <td>-0.058159</td>\n",
       "      <td>0.058159</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>day_Sat</th>\n",
       "      <td>0.054919</td>\n",
       "      <td>-0.002790</td>\n",
       "      <td>-0.041121</td>\n",
       "      <td>-0.053957</td>\n",
       "      <td>0.053957</td>\n",
       "      <td>-0.155744</td>\n",
       "      <td>0.155744</td>\n",
       "      <td>-0.216319</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.500682</td>\n",
       "      <td>-0.434480</td>\n",
       "      <td>0.462709</td>\n",
       "      <td>-0.462709</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>day_Sun</th>\n",
       "      <td>0.122953</td>\n",
       "      <td>0.125114</td>\n",
       "      <td>0.193054</td>\n",
       "      <td>-0.168106</td>\n",
       "      <td>0.168106</td>\n",
       "      <td>0.181624</td>\n",
       "      <td>-0.181624</td>\n",
       "      <td>-0.195451</td>\n",
       "      <td>-0.500682</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.392566</td>\n",
       "      <td>0.418071</td>\n",
       "      <td>-0.418071</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>day_Thur</th>\n",
       "      <td>-0.138174</td>\n",
       "      <td>-0.095879</td>\n",
       "      <td>-0.072598</td>\n",
       "      <td>0.194445</td>\n",
       "      <td>-0.194445</td>\n",
       "      <td>0.128534</td>\n",
       "      <td>-0.128534</td>\n",
       "      <td>-0.169608</td>\n",
       "      <td>-0.434480</td>\n",
       "      <td>-0.392566</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.917996</td>\n",
       "      <td>0.917996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time_Dinner</th>\n",
       "      <td>0.183118</td>\n",
       "      <td>0.121629</td>\n",
       "      <td>0.103411</td>\n",
       "      <td>-0.205231</td>\n",
       "      <td>0.205231</td>\n",
       "      <td>-0.054921</td>\n",
       "      <td>0.054921</td>\n",
       "      <td>-0.058159</td>\n",
       "      <td>0.462709</td>\n",
       "      <td>0.418071</td>\n",
       "      <td>-0.917996</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time_Lunch</th>\n",
       "      <td>-0.183118</td>\n",
       "      <td>-0.121629</td>\n",
       "      <td>-0.103411</td>\n",
       "      <td>0.205231</td>\n",
       "      <td>-0.205231</td>\n",
       "      <td>0.054921</td>\n",
       "      <td>-0.054921</td>\n",
       "      <td>0.058159</td>\n",
       "      <td>-0.462709</td>\n",
       "      <td>-0.418071</td>\n",
       "      <td>0.917996</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             total_bill       tip      size  sex_Female  sex_Male  smoker_No  \\\n",
       "total_bill     1.000000  0.675734  0.598315   -0.144877  0.144877  -0.085721   \n",
       "tip            0.675734  1.000000  0.489299   -0.088862  0.088862  -0.005929   \n",
       "size           0.598315  0.489299  1.000000   -0.086195  0.086195   0.133178   \n",
       "sex_Female    -0.144877 -0.088862 -0.086195    1.000000 -1.000000   0.002816   \n",
       "sex_Male       0.144877  0.088862  0.086195   -1.000000  1.000000  -0.002816   \n",
       "smoker_No     -0.085721 -0.005929  0.133178    0.002816 -0.002816   1.000000   \n",
       "smoker_Yes     0.085721  0.005929 -0.133178   -0.002816  0.002816  -1.000000   \n",
       "day_Fri       -0.086168 -0.055463 -0.142184    0.071060 -0.071060  -0.244316   \n",
       "day_Sat        0.054919 -0.002790 -0.041121   -0.053957  0.053957  -0.155744   \n",
       "day_Sun        0.122953  0.125114  0.193054   -0.168106  0.168106   0.181624   \n",
       "day_Thur      -0.138174 -0.095879 -0.072598    0.194445 -0.194445   0.128534   \n",
       "time_Dinner    0.183118  0.121629  0.103411   -0.205231  0.205231  -0.054921   \n",
       "time_Lunch    -0.183118 -0.121629 -0.103411    0.205231 -0.205231   0.054921   \n",
       "\n",
       "             smoker_Yes   day_Fri   day_Sat   day_Sun  day_Thur  time_Dinner  \\\n",
       "total_bill     0.085721 -0.086168  0.054919  0.122953 -0.138174     0.183118   \n",
       "tip            0.005929 -0.055463 -0.002790  0.125114 -0.095879     0.121629   \n",
       "size          -0.133178 -0.142184 -0.041121  0.193054 -0.072598     0.103411   \n",
       "sex_Female    -0.002816  0.071060 -0.053957 -0.168106  0.194445    -0.205231   \n",
       "sex_Male       0.002816 -0.071060  0.053957  0.168106 -0.194445     0.205231   \n",
       "smoker_No     -1.000000 -0.244316 -0.155744  0.181624  0.128534    -0.054921   \n",
       "smoker_Yes     1.000000  0.244316  0.155744 -0.181624 -0.128534     0.054921   \n",
       "day_Fri        0.244316  1.000000 -0.216319 -0.195451 -0.169608    -0.058159   \n",
       "day_Sat        0.155744 -0.216319  1.000000 -0.500682 -0.434480     0.462709   \n",
       "day_Sun       -0.181624 -0.195451 -0.500682  1.000000 -0.392566     0.418071   \n",
       "day_Thur      -0.128534 -0.169608 -0.434480 -0.392566  1.000000    -0.917996   \n",
       "time_Dinner    0.054921 -0.058159  0.462709  0.418071 -0.917996     1.000000   \n",
       "time_Lunch    -0.054921  0.058159 -0.462709 -0.418071  0.917996    -1.000000   \n",
       "\n",
       "             time_Lunch  \n",
       "total_bill    -0.183118  \n",
       "tip           -0.121629  \n",
       "size          -0.103411  \n",
       "sex_Female     0.205231  \n",
       "sex_Male      -0.205231  \n",
       "smoker_No      0.054921  \n",
       "smoker_Yes    -0.054921  \n",
       "day_Fri        0.058159  \n",
       "day_Sat       -0.462709  \n",
       "day_Sun       -0.418071  \n",
       "day_Thur       0.917996  \n",
       "time_Dinner   -1.000000  \n",
       "time_Lunch     1.000000  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 相关型矩阵\n",
    "df_dummpies.corr()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x7fb52b0af370>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAD2CAYAAAAAhSrIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAaiElEQVR4nO3df7hVZZ338fdH0zC1QKUER0KnsqQMjUrRlJp+kYOMjTWKPg3xPFKUXDPlD3B6HOkqHbWuuTTLTJkkHY2UacYwS3lSSATihz8QfzCWggrZhdVMyiP6RN/nj/s+cdrss8/e++y1916Hz+u6uM7a69x7re8SOt/udfa6P4oIzMzMirRbpwswM7PBz83GzMwK52ZjZmaFc7MxM7PCudmYmVnhXtHpArrRAQccEKNHj+50GWZmpbJmzZrnImJ4te+52VQxevRoVq9e3ekyzMxKRdLGvr7n22hmZlY4NxszMyucm42ZmRXOv7MZhEbP/mGnSzCzktpwyYmFHLf0MxtJYyWNrdh3ZafqMTOznZW+2QBj858/ioiZHarFzMyqKPVtNEmXAifn7akRMSFvL+61PQd4F/AaYBNwWkRs70S9Zma7qlLPbCJiFnAxcHFPc+nDsog4Fvg1MLnaAEnTJa2WtHrLli2tL9bMbBdW6mbTgFX56wPAIdUGRMQ1ETEuIsYNH171AVgzM2vSYGg2LwJ7A0hSH2Penb8eBfyiHUWZmdkOg6HZLAL+WtJy4Lg+xoyTtJT0e5sftK0yMzMDSv4BAYCI+A3wvop9EyqG/XNELG5XTZ1W1OfkzcyaVfpm05+ImNPpGszMdnWD4TaamZl1OTcbMzMrnJuNmZkVzs3GzMwK52ZjZmaFc7MxM7PCDfqPPu+KnGdjg5mfIysnz2zMzKxwbjZmZla4pppNtXTMZsb0Gru4n+/PkzS6j+/tlMpZ7Xj9ncPMzIrT7Mxmp3TMJscMWKtSOZ1nY2ZWnIabTU7H/AfgHyQtlvRKS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R19+HpNcDU9tY10D1e12SDgXGRMR7gB8Bf9beEptSz9/X6cCKiDgWGCPpLe0ssFmS9gLWUPtnQkt/frjZlNf7SKtvQwqDe2+TY7pNPTX/Crgib7/cjqJapN6/jytI4YNlUc91/QUwTNJPgfcAT7aptoGo57peAl6V/1//EEry7zEiXoyII4Bnagxr6c8PN5vy2h/477z9O2C/Jsd0m35rjojHI2KlpJNJYXh3tLG+gej32iRNAR4kRZyXRT3/zoYDWyLieNKspgzrItZzXTcBE4FHgcci4hdtqq0dWvrzw82mvJ4DXpO3X0P1tYzqGdNt6qo5x37/HTApIra3qbaBqufa/pI0C5gPvEPSWW2qbSDqua7fkQIUAZ6g+aTedqrnus4Hro6INwP7SRrfruLaoKU/P9xsyusn7PhdxfuAu5sc0236rTnHU5wLnBgRz7extoHq99oiYkpEHAecCqyJiK+3sb5m1fPvbA3wzrz9BlLD6Xb1XNe+wLa8/RI7EoUHg5b+/HCzKa8bgYMkrQV+A/xC0lf7GfOTNtfYjHqu62+BEcAdkpZKmtbuIptUz7WVUb/XFRHLgeckrQLWR8TKDtTZqHr+vr4BzJC0HNiLcvxvbCeSDin654dXEDAzs8J5ZmNmZoVzszEzs8K52ZiZWeHcbMzMrHBuNmZmVjg3GzMzK9z/Bz2BaJfkmGJgAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df_dummpies.corr()[\"tip\"].sort_values().plot.barh()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
